﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using MyUtils;

namespace Test.MyUtils
{
	[TestClass]
	public class HumanReadableIdentifiers
	{
		static void check(string expect, string input)
		{
			Assert.AreEqual(expect, Utils.HumanReadable(input));
		}

		static void check2(string expect, string input)
		{
			check(expect, input);
			checkEWUC(expect, input);
		}

		static void checkEWUC(string expect, string input)
		{
			Assert.AreEqual(expect, Utils.HumanReadableStartCase(input));
		}

		[TestMethod]
		public void should_not_hang_on_bad_names()
		{
			check2("Should", "Should_");
			check2("Should_", "Should__");
			check2("Should", "_Should");
			check2("Should_2", "Should__2");
			check2("Should _2", "Should __2");
			check2("_should", "__should");
			check("_ should", "__ Should");
			checkEWUC("_ Should", "__ Should");
		}

		[TestMethod]
		public void Should_use_human_readable_identifer()
		{
			check("Camel case syntax", "camelCaseSyntax");
			check("Camel case syntax", " camelCaseSyntax ");
			check("Pascal case syntax", "PascalCaseSyntax");
			check("Pascal case syntax", " PascalCaseSyntax ");
			check("Ruby style syntax", "Ruby_style_syntax");
			check("Ruby style syntax", " Ruby_style_syntax ");
			check("First capital letter", "first_Capital_letter");
		}

		[TestMethod]
		public void Should_use_human_readable_identifer_with_each_word_uppercase()
		{
			checkEWUC("Camel Case Syntax", "camelCaseSyntax");
			checkEWUC("Camel Case Syntax", " camelCaseSyntax ");
			checkEWUC("Pascal Case Syntax", "PascalCaseSyntax");
			checkEWUC("Pascal Case Syntax", " PascalCaseSyntax ");
			checkEWUC("Ruby Style Syntax", "Ruby_style_syntax");
			checkEWUC("Ruby Style Syntax", " Ruby_style_syntax ");
			checkEWUC("First Capital Letter", "first_Capital_letter");
		}
	}
}